<?php
/*
+--------------------------------------------------------------------------
|   Web: http://www.enbac.com 
|   Started date : 30/06/2008
+---------------------------------------------------------------------------
|   > Script written by Nova
+---------------------------------------------------------------------------
*/

if (eregi(basename( __FILE__ ), $_SERVER['PHP_SELF'])) {
	print "<h1>Incorrect access</h1>You cannot access this file directly.";
	exit();
}

class xml_item {
	
    	function playme()
    	{	
    		
    		$code = AZLib::getParam('code');
			switch( $code )
			{
				case 'tiltviewer_gallery':
					
					$this->tiltviewer_gallery();
					break;
				case 'piclens_gallery':
					$this->piclens_gallery();
					break;
												
				default:
					$this->home();
					break;
			}

			//$print->html = $skin->index();
			//$print->display();
		}




function home()
{
	//echo urlencode("ebxml.php?act=item&code=tiltviewer_gallery&item_id=3414");
	
	die("no_action");
}

function tiltviewer_gallery()
{
	$item_id  = AZLib::getParam('item_id');
	
	if( $item_id )
	{
		 $sql='select id, img_url, title, position from item_image where item_id = '.intval($item_id).' ORDER BY position ';
		 DB::query($sql);
			
		 if(DB::num_rows()){
		
			 $entry='';	 	
		 	 while($rows = DB::fetch_row()){
		 	 	$rows['title'] = ($rows['title']) ? $rows['title'] : "Image {$rows['position']}";
		 	 	
		 	 	$rows['title'] = trim( XMLLib::_xml_encode_attribute($rows['title']));
		 	 	
		 	 	if(eregi('/',$rows['img_url']))
		 	 		$url = trim( XMLLib::_xml_encode_attribute("http://".IMAGE_PATH."{$rows['img_url']}"));
		 	 	else
		 	 		$url = trim( XMLLib::_xml_encode_attribute("http://".IMAGE_PATH."uploaded/items/{$rows['img_url']}"));
		 	 	//$rows['description'] = 	trim( XMLLib::_xml_encode_attribute(html_entity_decode( $rows['description'], ENT_QUOTES, "UTF-8")));	
		 	 	 	
			 	 $entry .="
						<photo imageurl=\"$url\" linkurl=\"http://www.enbac.com\">
							<title>{$rows['title']}</title>
						</photo>		 	 	
			 	 	";		 			 	 
		 	 }

		 	 
		 	 @header( "Content-type: text/xml" );
		 	 echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?".'>';
		 	 echo "<tiltviewergallery><photos>";
		 	 echo $entry;
		 	 echo "</photos></tiltviewergallery>";
		 }
		 else 
		 {
		 	die("no_info");
		 }
	}
	else
	{
		die("no_info");
	}
}

function piclens_gallery()
{
	$item_id  = AZLib::getParam('item_id');
	$entry = '';
	
	if( $item_id )
	{
		 $sql='select id, img_url, title, position from item_image where item_id = '.intval($item_id).' ORDER BY position ';
		 DB::query($sql);
		
		 if(DB::num_rows()){
		 	$entry='';
		 	 while($rows = DB::fetch_row()){
		 	 	$rows['title'] = ($rows['title']) ? $rows['title'] : "Image {$rows['position']}";
		 	 	$rows['title'] = trim( XMLLib::_xml_encode_attribute($rows['title']));
		 	 	
		 	 	if(ereg('/',$rows['img_url']))
		 	 		$url = trim( XMLLib::_xml_encode_attribute("http://".IMAGE_PATH."{$rows['img_url']}"));
		 	 	else
		 	 		$url = trim( XMLLib::_xml_encode_attribute("http://".IMAGE_PATH."uploaded/items/{$rows['img_url']}"));
		 	 	
		 	 	$entry .="
		 	 	<item>
		 	 			<title>".stripslashes($rows['title'])."</title>
						<link>$url</link>
						<guid>Image {$rows['position']}</guid>
						<media:thumbnail url=\"$url\" />
						<media:content url=\"$url\" />
				</item>
		 	 	";
		 	 }
		 	 
		 	 @header( "Content-type: text/xml" );
			 echo "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
			 <rss version=\"2.0\" xmlns:media=\"http://search.yahoo.com/mrss\">
			 <channel>			
			 <title>Enbac.com</title>
			 <link>http://www.enbac.com/</link>
			 <description>Enbac.com - </description>
			 <logo url=\"style/images/logo.piclens.png\" />
			";
		 	 echo $entry;
		 	 echo "
		 	 </channel>
			 </rss>
			";
		 	 
		 }
		 else 
		 {
		 	die("no_info");
		 }
	}
	else
	{
		die("no_info");
	}
}



}//class

?>